<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends BaseController {
    public function index(){
		
		if($_SESSION['admin']['user']['role']==1){
			$cache=M('admin_auth_rule')->where(array('isnemu'=>1))->order('list_order ASC, id ASC')->select();
		}else{
			$cache=M('admin_auth_rule')->where(array('isnemu'=>1))->order('list_order ASC, id ASC')->select();
			//$access=M('admin_access')->field('nid')->where(array('rid'=>$_SESSION['admin']['user']['role']))->select();
			//$cache=M('admin_auth_rule')->where(array('id'=>array('in',two_array_one($access,'nid'))))->order('list_order ASC, id ASC')->select();
		}
		$cache=\bb\Data::channelLevel($cache, 0, '-', 'id');
		
		//p($cache);
		$this->assign('cache',$cache);
		$this->display();
    }
	
	public function main(){
		//p($_SESSION);
		echo "这是首页！";
    }
	
	//网站设置
	public function zhandianset(){
		$m=M('system');
		if(IS_POST){
			$p=I('post.');
			$re=$m->save($p);
			if($re){
				$info['status']=1;
				$info['msg']='修改成功！';
			}else{
				$info['status']=0;
				$info['msg']='修改失败！';
			}
			$this->ajaxreturn($info);
		}

		$data=$m->find();
		$this->assign('cache',$data);
		$this->display();
	}
	
	public function jifenset(){
		$m=M('bb_user_set');
		if(IS_POST){
			$post = I('post.');
			if($post['isgift']==1){
				$post['gift_detail']=$post['gift_type'].",".$post['gift_money'].",".$post['gift_days'].",".$post['gift_usemoney'];
			}
			unset($post['gift_type']);
			unset($post['gift_money']);
			unset($post['gift_days']);
			unset($post['gift_usemoney']);
			$re=$m->save($post);
			if($re){
				$info['status']=1;
				$info['msg']='修改成功！';
			}else{
				$info['status']=0;
				$info['msg']='修改失败！';
			}
			$this->ajaxreturn($info);
		}
		$cache=$m->where('id=1')->find();
		if($cache['isgift']==1) {
				$gift=explode(",", $cache['gift_detail']);
				$cache['gift_type']=$gift[0];
				$cache['gift_money']=$gift[1];
				$cache['gift_days']=$gift[2];
				$cache['gift_usemoney']=$gift[3];
			}
		$this->assign('cache',$cache);
		$this->display();
	}
	
	public function auntieset(){
		$m=M('bb_user_set');
		if(IS_POST){
			$post = I('post.');
			$re=$m->save($post);
			if($re){
				$info['status']=1;
				$info['msg']='修改成功！';
			}else{
				$info['status']=0;
				$info['msg']='修改失败！';
			}
			$this->ajaxreturn($info);
		}
		$cache=$m->where('id=1')->find();
		$this->assign('cache',$cache);
		$this->display();
	}
	
	
	public function tongji_u(){

		
		$dangqiansj = !empty($_GET['date']) ? strtotime($_GET['date']): time();
		$this->assign('dangqiansj',date('Y-m-d',$dangqiansj));
		$day = $_GET['day'] ? $_GET['day']: 0;
		
		if($day == 0){
			$chart = new \Org\GoogChart();	

			$time= date('Y-m-d',$dangqiansj).' 00:00:00';

			$lastday=date("Y-m-d",strtotime("$time Sunday"));


			$data0 = "'".date("Y-m-d",strtotime("$lastday - 6 days"))
				."','".date("Y-m-d",strtotime("$lastday - 5 days"))
				."','".date("Y-m-d",strtotime("$lastday - 4 days"))
				."','".date("Y-m-d",strtotime("$lastday - 3 days"))
				."','".date("Y-m-d",strtotime("$lastday - 2 days"))
				."','".date("Y-m-d",strtotime("$lastday - 1 days"))
				."','".date("Y-m-d",strtotime("$lastday - 0 days"))."'";
			$this->assign('data0',$data0);

			$array_f[0]=date("Y-m-d",strtotime("$lastday - 6 days"));
			$array_f[1]=date("Y-m-d",strtotime("$lastday - 5 days"));
			$array_f[2]=date("Y-m-d",strtotime("$lastday - 4 days"));
			$array_f[3]=date("Y-m-d",strtotime("$lastday - 3 days"));
			$array_f[4]=date("Y-m-d",strtotime("$lastday - 2 days"));
			$array_f[5]=date("Y-m-d",strtotime("$lastday - 1 days"));
			$array_f[6]=date("Y-m-d",strtotime("$lastday - 0 days"));

			$m = M('weixin_client_user');
			$num_f ="";
			foreach($array_f as $k=>$value)
			{
			$where['subscribe_time']=array(array('egt',strtotime($array_f[$k]."00.00.00")),array('elt',strtotime($array_f[$k]."24.00.00")),'AND');
			$num = $m->where($where)->count();
			$num_f .= $num.",";
			}
			$num_f = substr($num_f, 0, -1);

			$this->assign('data',$num_f);	
				
			$this -> display();
		}elseif($day == 1){
			$j = date(j,$dangqiansj); //获取当前月份天数
			
			$start_time = strtotime(date('Y-m-01',$dangqiansj));  //获取本月第一天时间戳
			$array = array();
			for($i=0;$i<$j;$i++){
				 $array[] = date('Y-m-d',$start_time+$i*86400); //每隔一天赋值给数组
			}
			$data0='';
			foreach($array as $k=>$value){
				$data0 .="'".$value."'".",";
			}
			$data0 = substr($data0, 0, -1);
			
			$this->assign('data0',$data0);	
			
			
			$m = M('weixin_client_user');
			$num_f ="";
			foreach($array as $k=>$value)
			{
			$where['subscribe_time']=array(array('egt',strtotime($array[$k]."00.00.00")),array('elt',strtotime($array[$k]."24.00.00")),'AND');
			$num = $m->where($where)->count();
			$num_f .= $num.",";
			}
			$num_f = substr($num_f, 0, -1);
			
			$this->assign('data',$num_f);	
			
			
			$this -> display();

		}elseif($day == 2){
			$y = date(Y,$dangqiansj); //获取当前月份天数
			$array[0]=$y."-01-01";
			$array[1]=$y."-02-01";
			$array[2]=$y."-03-01";
			$array[3]=$y."-04-01";
			$array[4]=$y."-05-01";
			$array[5]=$y."-06-01";
			$array[6]=$y."-07-01";
			$array[7]=$y."-08-01";
			$array[8]=$y."-09-01";
			$array[9]=$y."-10-01";
			$array[10]=$y."-11-01";
			$array[11]=$y."-12-01";
			
			$data0='';
			foreach($array as $k=>$value){
				$data0 .="'".$value."'".",";
			}
			$data0 = substr($data0, 0, -1);
			
			$this->assign('data0',$data0);	
			
			
			$m = M('weixin_client_user');
			$num_f ="";
			foreach($array as $k=>$value)
			{
			if($k == 11){
				$where['subscribe_time']=array(array('egt',strtotime($array[$k]."00.00.00")),array('elt',strtotime(($y+1)."-01-01"."00.00.00")),'AND');
				$num = $m->where($where)->count();
				$num_f .= $num.",";	
			}else{
				$where['subscribe_time']=array(array('egt',strtotime($array[$k]."00.00.00")),array('elt',strtotime($array[$k+1]."00.00.00")),'AND');
				$num = $m->where($where)->count();
				$num_f .= $num.",";	
			}
			
			}
			$num_f = substr($num_f, 0, -1);
			
			$this->assign('data',$num_f);	
			
			
			$this -> display();

		}
		
		


					
	}
	
	
	
	public function tongji_b(){
		$dangqiansj = !empty($_GET['date']) ? strtotime($_GET['date']): time();
		$this->assign('dangqiansj',date('Y-m-d',$dangqiansj));
		$day = $_GET['day'] ? $_GET['day']: 0;
		
		if($day == 0){
			$chart = new \Org\GoogChart();	

			$time= date('Y-m-d',$dangqiansj).' 00:00:00';

			$lastday=date("Y-m-d",strtotime("$time Sunday"));


			$data0 = "'".date("Y-m-d",strtotime("$lastday - 6 days"))
				."','".date("Y-m-d",strtotime("$lastday - 5 days"))
				."','".date("Y-m-d",strtotime("$lastday - 4 days"))
				."','".date("Y-m-d",strtotime("$lastday - 3 days"))
				."','".date("Y-m-d",strtotime("$lastday - 2 days"))
				."','".date("Y-m-d",strtotime("$lastday - 1 days"))
				."','".date("Y-m-d",strtotime("$lastday - 0 days"))."'";
			$this->assign('data0',$data0);

			$array_f[0]=date("Y-m-d",strtotime("$lastday - 6 days"));
			$array_f[1]=date("Y-m-d",strtotime("$lastday - 5 days"));
			$array_f[2]=date("Y-m-d",strtotime("$lastday - 4 days"));
			$array_f[3]=date("Y-m-d",strtotime("$lastday - 3 days"));
			$array_f[4]=date("Y-m-d",strtotime("$lastday - 2 days"));
			$array_f[5]=date("Y-m-d",strtotime("$lastday - 1 days"));
			$array_f[6]=date("Y-m-d",strtotime("$lastday - 0 days"));

			$m = M('bb_shop');
			$num_f ="";
			foreach($array_f as $k=>$value)
			{
			$where['createtm']=array(array('egt',$array_f[$k]." 00.00.00"),array('elt',$array_f[$k]." 24.00.00"),'AND');
			$num = $m->where($where)->count();
			$num_f .= $num.",";
			}
			$num_f = substr($num_f, 0, -1);

			$this->assign('data',$num_f);	
				
			$this -> display();
		}elseif($day == 1){
			$j = date(j,$dangqiansj); //获取当前月份天数
			
			$start_time = strtotime(date('Y-m-01',$dangqiansj));  //获取本月第一天时间戳
			$array = array();
			for($i=0;$i<$j;$i++){
				 $array[] = date('Y-m-d',$start_time+$i*86400); //每隔一天赋值给数组
			}
			$data0='';
			foreach($array as $k=>$value){
				$data0 .="'".$value."'".",";
			}
			$data0 = substr($data0, 0, -1);
			
			$this->assign('data0',$data0);	
			
			
			$m = M('bb_shop');
			$num_f ="";
			foreach($array as $k=>$value)
			{
			$where['createtm']=array(array('egt',$array[$k]." 00.00.00"),array('elt',$array[$k]." 24.00.00"),'AND');
			
			$num = $m->where($where)->count();
			$num_f .= $num.",";
			}
			$num_f = substr($num_f, 0, -1);
			
			$this->assign('data',$num_f);	
			
			
			$this -> display();

		}elseif($day == 2){
			$y = date(Y,$dangqiansj); //获取当前月份天数
			$array[0]=$y."-01-01";
			$array[1]=$y."-02-01";
			$array[2]=$y."-03-01";
			$array[3]=$y."-04-01";
			$array[4]=$y."-05-01";
			$array[5]=$y."-06-01";
			$array[6]=$y."-07-01";
			$array[7]=$y."-08-01";
			$array[8]=$y."-09-01";
			$array[9]=$y."-10-01";
			$array[10]=$y."-11-01";
			$array[11]=$y."-12-01";
			
			$data0='';
			foreach($array as $k=>$value){
				$data0 .="'".$value."'".",";
			}
			$data0 = substr($data0, 0, -1);
			
			$this->assign('data0',$data0);	
			
			
			$m = M('bb_shop');
			$num_f ="";
			foreach($array as $k=>$value)
			{
			if($k == 11){
				$where['createtm']=array(array('egt',$array[$k]." 00.00.00"),array('elt',($y+1)."-01-01"." 00.00.00"),'AND');
				$num = $m->where($where)->count();
				$num_f .= $num.",";	
			}else{
				$where['createtm']=array(array('egt',$array[$k]." 00.00.00"),array('elt',$array[$k+1]." 00.00.00"),'AND');
				$num = $m->where($where)->count();
				$num_f .= $num.",";	
			}
			
			}
			$num_f = substr($num_f, 0, -1);
			
			$this->assign('data',$num_f);	
			
			
			$this -> display();

		}
	}
	
	public function tongji_a(){
		$dangqiansj = !empty($_GET['date']) ? strtotime($_GET['date']): time();
		$this->assign('dangqiansj',date('Y-m-d',$dangqiansj));
		$day = $_GET['day'] ? $_GET['day']: 0;
		
		if($day == 0){
			$chart = new \Org\GoogChart();	

			$time= date('Y-m-d',$dangqiansj).' 00:00:00';

			$lastday=date("Y-m-d",strtotime("$time Sunday"));


			$data0 = "'".date("Y-m-d",strtotime("$lastday - 6 days"))
				."','".date("Y-m-d",strtotime("$lastday - 5 days"))
				."','".date("Y-m-d",strtotime("$lastday - 4 days"))
				."','".date("Y-m-d",strtotime("$lastday - 3 days"))
				."','".date("Y-m-d",strtotime("$lastday - 2 days"))
				."','".date("Y-m-d",strtotime("$lastday - 1 days"))
				."','".date("Y-m-d",strtotime("$lastday - 0 days"))."'";
			$this->assign('data0',$data0);

			$array_f[0]=date("Y-m-d",strtotime("$lastday - 6 days"));
			$array_f[1]=date("Y-m-d",strtotime("$lastday - 5 days"));
			$array_f[2]=date("Y-m-d",strtotime("$lastday - 4 days"));
			$array_f[3]=date("Y-m-d",strtotime("$lastday - 3 days"));
			$array_f[4]=date("Y-m-d",strtotime("$lastday - 2 days"));
			$array_f[5]=date("Y-m-d",strtotime("$lastday - 1 days"));
			$array_f[6]=date("Y-m-d",strtotime("$lastday - 0 days"));

			$m = M('bb_agent');
			$num_f ="";
			foreach($array_f as $k=>$value)
			{
			$where['addtime']=array(array('egt',$array_f[$k]." 00.00.00"),array('elt',$array_f[$k]." 24.00.00"),'AND');
			$num = $m->where($where)->count();
			$num_f .= $num.",";
			}
			$num_f = substr($num_f, 0, -1);

			$this->assign('data',$num_f);	
				
			$this -> display();
		}elseif($day == 1){
			$j = date(j,$dangqiansj); //获取当前月份天数
			
			$start_time = strtotime(date('Y-m-01',$dangqiansj));  //获取本月第一天时间戳
			$array = array();
			for($i=0;$i<$j;$i++){
				 $array[] = date('Y-m-d',$start_time+$i*86400); //每隔一天赋值给数组
			}
			$data0='';
			foreach($array as $k=>$value){
				$data0 .="'".$value."'".",";
			}
			$data0 = substr($data0, 0, -1);
			
			$this->assign('data0',$data0);	
			
			
			$m = M('bb_agent');
			$num_f ="";
			foreach($array as $k=>$value)
			{
			$where['addtime']=array(array('egt',$array[$k]." 00.00.00"),array('elt',$array[$k]." 24.00.00"),'AND');
			
			$num = $m->where($where)->count();
			$num_f .= $num.",";
			}
			$num_f = substr($num_f, 0, -1);
			
			$this->assign('data',$num_f);	
			
			
			$this -> display();

		}elseif($day == 2){
			$y = date(Y,$dangqiansj); //获取当前月份天数
			$array[0]=$y."-01-01";
			$array[1]=$y."-02-01";
			$array[2]=$y."-03-01";
			$array[3]=$y."-04-01";
			$array[4]=$y."-05-01";
			$array[5]=$y."-06-01";
			$array[6]=$y."-07-01";
			$array[7]=$y."-08-01";
			$array[8]=$y."-09-01";
			$array[9]=$y."-10-01";
			$array[10]=$y."-11-01";
			$array[11]=$y."-12-01";
			
			$data0='';
			foreach($array as $k=>$value){
				$data0 .="'".$value."'".",";
			}
			$data0 = substr($data0, 0, -1);
			
			$this->assign('data0',$data0);	
			
			
			$m = M('bb_agent');
			$num_f ="";
			foreach($array as $k=>$value)
			{
			if($k == 11){
				$where['addtime']=array(array('egt',$array[$k]." 00.00.00"),array('elt',($y+1)."-01-01"." 00.00.00"),'AND');
				$num = $m->where($where)->count();
				$num_f .= $num.",";	
			}else{
				$where['addtime']=array(array('egt',$array[$k]." 00.00.00"),array('elt',$array[$k+1]." 00.00.00"),'AND');
				$num = $m->where($where)->count();
				$num_f .= $num.",";	
			}
			
			}
			$num_f = substr($num_f, 0, -1);
			
			$this->assign('data',$num_f);	
			
			
			$this -> display();

		}

	}
	
	public function tongji_o(){
		
				$dangqiansj = !empty($_GET['date']) ? strtotime($_GET['date']): time();
		$this->assign('dangqiansj',date('Y-m-d',$dangqiansj));
		$day = $_GET['day'] ? $_GET['day']: 0;
		
		if($day == 0){
			$chart = new \Org\GoogChart();	

			$time= date('Y-m-d',$dangqiansj).' 00:00:00';

			$lastday=date("Y-m-d",strtotime("$time Sunday"));


			$data0 = "'".date("Y-m-d",strtotime("$lastday - 6 days"))
				."','".date("Y-m-d",strtotime("$lastday - 5 days"))
				."','".date("Y-m-d",strtotime("$lastday - 4 days"))
				."','".date("Y-m-d",strtotime("$lastday - 3 days"))
				."','".date("Y-m-d",strtotime("$lastday - 2 days"))
				."','".date("Y-m-d",strtotime("$lastday - 1 days"))
				."','".date("Y-m-d",strtotime("$lastday - 0 days"))."'";
			$this->assign('data0',$data0);

			$array_f[0]=date("Y-m-d",strtotime("$lastday - 6 days"));
			$array_f[1]=date("Y-m-d",strtotime("$lastday - 5 days"));
			$array_f[2]=date("Y-m-d",strtotime("$lastday - 4 days"));
			$array_f[3]=date("Y-m-d",strtotime("$lastday - 3 days"));
			$array_f[4]=date("Y-m-d",strtotime("$lastday - 2 days"));
			$array_f[5]=date("Y-m-d",strtotime("$lastday - 1 days"));
			$array_f[6]=date("Y-m-d",strtotime("$lastday - 0 days"));

			$m = M('bb_order');
			$num_f ="";
			foreach($array_f as $k=>$value)
			{
			$where['addtime']=array(array('egt',$array_f[$k]." 00.00.00"),array('elt',$array_f[$k]." 24.00.00"),'AND');
			$num = $m->where($where)->count();
			$num_f .= $num.",";
			}
			$num_f = substr($num_f, 0, -1);

			$this->assign('data',$num_f);	
				
			$this -> display();
		}elseif($day == 1){
			$j = date(j,$dangqiansj); //获取当前月份天数
			
			$start_time = strtotime(date('Y-m-01',$dangqiansj));  //获取本月第一天时间戳
			$array = array();
			for($i=0;$i<$j;$i++){
				 $array[] = date('Y-m-d',$start_time+$i*86400); //每隔一天赋值给数组
			}
			$data0='';
			foreach($array as $k=>$value){
				$data0 .="'".$value."'".",";
			}
			$data0 = substr($data0, 0, -1);
			
			$this->assign('data0',$data0);	
			
			
			$m = M('bb_order');
			$num_f ="";
			foreach($array as $k=>$value)
			{
			$where['addtime']=array(array('egt',$array[$k]." 00.00.00"),array('elt',$array[$k]." 24.00.00"),'AND');
			
			$num = $m->where($where)->count();
			$num_f .= $num.",";
			}
			$num_f = substr($num_f, 0, -1);
			
			$this->assign('data',$num_f);	
			
			
			$this -> display();

		}elseif($day == 2){
			$y = date(Y,$dangqiansj); //获取当前月份天数
			$array[0]=$y."-01-01";
			$array[1]=$y."-02-01";
			$array[2]=$y."-03-01";
			$array[3]=$y."-04-01";
			$array[4]=$y."-05-01";
			$array[5]=$y."-06-01";
			$array[6]=$y."-07-01";
			$array[7]=$y."-08-01";
			$array[8]=$y."-09-01";
			$array[9]=$y."-10-01";
			$array[10]=$y."-11-01";
			$array[11]=$y."-12-01";
			
			$data0='';
			foreach($array as $k=>$value){
				$data0 .="'".$value."'".",";
			}
			$data0 = substr($data0, 0, -1);
			
			$this->assign('data0',$data0);	
			
			
			$m = M('bb_order');
			$num_f ="";
			foreach($array as $k=>$value)
			{
			if($k == 11){
				$where['addtime']=array(array('egt',$array[$k]." 00.00.00"),array('elt',($y+1)."-01-01"." 00.00.00"),'AND');
				$num = $m->where($where)->count();
				$num_f .= $num.",";	
			}else{
				$where['addtime']=array(array('egt',$array[$k]." 00.00.00"),array('elt',$array[$k+1]." 00.00.00"),'AND');
				$num = $m->where($where)->count();
				$num_f .= $num.",";	
			}
			
			}
			$num_f = substr($num_f, 0, -1);
			
			$this->assign('data',$num_f);	
			
			
			$this -> display();

		}

	}
	
	public function tongji_p(){
		
		$dangqiansj = !empty($_GET['date']) ? strtotime($_GET['date']): time();
		$this->assign('dangqiansj',date('Y-m-d',$dangqiansj));
		$day = $_GET['day'] ? $_GET['day']: 0;
		
		if($day == 0){
			$chart = new \Org\GoogChart();	

			$time= date('Y-m-d',$dangqiansj).' 00:00:00';

			$lastday=date("Y-m-d",strtotime("$time Sunday"));


			$data0 = "'".date("Y-m-d",strtotime("$lastday - 6 days"))
				."','".date("Y-m-d",strtotime("$lastday - 5 days"))
				."','".date("Y-m-d",strtotime("$lastday - 4 days"))
				."','".date("Y-m-d",strtotime("$lastday - 3 days"))
				."','".date("Y-m-d",strtotime("$lastday - 2 days"))
				."','".date("Y-m-d",strtotime("$lastday - 1 days"))
				."','".date("Y-m-d",strtotime("$lastday - 0 days"))."'";
			$this->assign('data0',$data0);

			$array_f[0]=date("Y-m-d",strtotime("$lastday - 6 days"));
			$array_f[1]=date("Y-m-d",strtotime("$lastday - 5 days"));
			$array_f[2]=date("Y-m-d",strtotime("$lastday - 4 days"));
			$array_f[3]=date("Y-m-d",strtotime("$lastday - 3 days"));
			$array_f[4]=date("Y-m-d",strtotime("$lastday - 2 days"));
			$array_f[5]=date("Y-m-d",strtotime("$lastday - 1 days"));
			$array_f[6]=date("Y-m-d",strtotime("$lastday - 0 days"));

			$m = M('bb_order');
			$num_f ="";
			foreach($array_f as $k=>$value)
			{
			$where['addtime']=array(array('egt',$array_f[$k]." 00.00.00"),array('elt',$array_f[$k]." 24.00.00"),'AND');
			$where['is_pay']=array('eq',1);
			$num = $m->where($where)->count();
			$num_f .= $num.",";
			}
			$num_f = substr($num_f, 0, -1);

			$this->assign('data',$num_f);	
				
			$this -> display();
		}elseif($day == 1){
			$j = date(j,$dangqiansj); //获取当前月份天数
			
			$start_time = strtotime(date('Y-m-01',$dangqiansj));  //获取本月第一天时间戳
			$array = array();
			for($i=0;$i<$j;$i++){
				 $array[] = date('Y-m-d',$start_time+$i*86400); //每隔一天赋值给数组
			}
			$data0='';
			foreach($array as $k=>$value){
				$data0 .="'".$value."'".",";
			}
			$data0 = substr($data0, 0, -1);
			
			$this->assign('data0',$data0);	
			
			
			$m = M('bb_order');
			$num_f ="";
			foreach($array as $k=>$value)
			{
			$where['addtime']=array(array('egt',$array[$k]." 00.00.00"),array('elt',$array[$k]." 24.00.00"),'AND');
			$where['is_pay']=array('eq',1);
			$num = $m->where($where)->count();
			$num_f .= $num.",";
			}
			$num_f = substr($num_f, 0, -1);
			
			$this->assign('data',$num_f);	
			
			
			$this -> display();

		}elseif($day == 2){
			$y = date(Y,$dangqiansj); //获取当前月份天数
			$array[0]=$y."-01-01";
			$array[1]=$y."-02-01";
			$array[2]=$y."-03-01";
			$array[3]=$y."-04-01";
			$array[4]=$y."-05-01";
			$array[5]=$y."-06-01";
			$array[6]=$y."-07-01";
			$array[7]=$y."-08-01";
			$array[8]=$y."-09-01";
			$array[9]=$y."-10-01";
			$array[10]=$y."-11-01";
			$array[11]=$y."-12-01";
			
			$data0='';
			foreach($array as $k=>$value){
				$data0 .="'".$value."'".",";
			}
			$data0 = substr($data0, 0, -1);
			
			$this->assign('data0',$data0);	
			
			
			$m = M('bb_order');
			$num_f ="";
			foreach($array as $k=>$value)
			{
			if($k == 11){
				$where['addtime']=array(array('egt',$array[$k]." 00.00.00"),array('elt',($y+1)."-01-01"." 00.00.00"),'AND');
				$where['is_pay']=array('eq',1);
				$num = $m->where($where)->count();
				$num_f .= $num.",";	
			}else{
				$where['addtime']=array(array('egt',$array[$k]." 00.00.00"),array('elt',$array[$k+1]." 00.00.00"),'AND');
				$where['is_pay']=array('eq',1);
				$num = $m->where($where)->count();
				$num_f .= $num.",";	
			}
			
			}
			$num_f = substr($num_f, 0, -1);
			
			$this->assign('data',$num_f);	
			
			
			$this -> display();

		}

	}
	
	public function sgtc(){
		$p=$_GET['p']?$_GET['p']:1;
		$psize=C('BB_PSIZE')?C('BB_PSIZE'):20;

		
		$bb_txorder = M('bb_txorder');
		$cache = $bb_txorder->where('status = 0')->page($p,$psize)->order('id asc')->select();
		
		

		$count=$bb_txorder->where('status = 0')->count();
		$this->getPage($count, $psize, 'bb-loader', '手工提成','bb-search');
		
		
		$user = M('bb_auntie');
		
		
		foreach($cache as $k => $v){
			$list=$user->where('openid = "'.$v['openid'].'"')->find();
			$cache[$k]['name']=$list['name'];
			$cache[$k]['phone'] = $list['phone'];

		}
		
		
		
		
		
		
		$this->assign('cache',$cache);
		

		
		$this->display();
	}
	
	public function doaytc(){
		if($_GET['id']){

			$data['status']=1;
			$data['overtime']=time();
			if(M('bb_txorder')->where('id = '.$_GET['id'])->save($data)){
				echo 1;die;
			}
		}
			
	}
	
	public function lsjl(){
		$p=$_GET['p']?$_GET['p']:1;
		$psize=C('BB_PSIZE')?C('BB_PSIZE'):20;

		
		$bb_txorder = M('bb_txorder');
		$cache = $bb_txorder->where('status = 1')->page($p,$psize)->order('id asc')->select();
		
		

		$count=$bb_txorder->where('status = 1')->count();
		$this->getPage($count, $psize, 'bb-loader', '手工提成','bb-search');
		
		
		$user = M('bb_auntie');
		
		
		foreach($cache as $k => $v){
			$list=$user->where('openid = "'.$v['openid'].'"')->find();
			$cache[$k]['name']=$list['name'];
			$cache[$k]['phone'] = $list['phone'];

		}
		
		
		
		
		
		
		$this->assign('cache',$cache);
		

		
		$this->display();
	}
	
	
	public function sjfx(){
		$m=M('client_user');
		$p=$_GET['p']?$_GET['p']:1;
		$psize=C('BB_PSIZE')?C('BB_PSIZE'):20;
		if(I('name')){
			$search=I('name');
			$map['name']=array('like',"%$search%");
			$map['username'] = array('like',"%$search%");
			$map['_logic'] = 'OR';
		}
		$data=$m->where($map)->page($p,$psize)->order('addtime desc')->select();
		$count=$m->where($map)->count();
		$this->getPage($count, $psize, 'bb-loader', '会员管理','bb-search');
		foreach ($data as $k => $v){
			$wxuser=M('weixin_client_user')->field('headimgurl')->where(array('openid'=>$v['openid']))->find();
			$data[$k]['headimgurl']=$wxuser['headimgurl'];
			
			$map_fx['path'] = array('like','%,'.$data[$k]['id'].'%');
			$map_fx1 = array();
			$map_fx2 = array();
			$map_fx3 = array();
			$fx=$m->where($map_fx)->select();
			
			foreach($fx as $kv=>$vv){
				$fx_a=explode(',',$vv['path']);
				foreach($fx_a as $ke => $ve){
					if($ve == $data[$k]['id'] ){
						switch ($ke)
						{
						case count($fx_a)-1:
						  $map_fx1[] = $vv['id'];
						  break;  
						case count($fx_a)-2:
						  $map_fx2[] = $vv['id'];
						  break;
						  
						case count($fx_a)-3:
						   $map_fx3[] = $vv['id'];
						  break;
						  
						default:
							
						}
						break;
					}
				}
			}
			$data[$k]['fx1'] = count($map_fx1);
			$data[$k]['fx2'] = count($map_fx2);
			$data[$k]['fx3'] = count($map_fx3);
			$data[$k]['fx_count'] = count($map_fx1)+count($map_fx2)+count($map_fx3);
			
			
			
		}
		$this->assign('cache',$data);
		$this->display();
	}
	
	
	public function sjfx_xx(){
		$m=M('client_user');
		$map['id'] = $_GET['id'];
		$data=$m->where($map)->select();
		
		foreach ($data as $k => $v){
			$wxuser=M('weixin_client_user')->field('headimgurl')->where(array('openid'=>$v['openid']))->find();
			$data[$k]['headimgurl']=$wxuser['headimgurl'];
			
			$map_fx['path'] = array('like','%,'.$data[$k]['id'].'%');
			$map_fx1 = array();
			$map_fx2 = array();
			$map_fx3 = array();
			$fx=$m->where($map_fx)->select();
			
			foreach($fx as $kv=>$vv){
				$fx_a=explode(',',$vv['path']);
				foreach($fx_a as $ke => $ve){
					if($ve == $data[$k]['id'] ){
						switch ($ke)
						{
						case count($fx_a)-1:
						  $map_fx1[] = $vv['id'];
						  break;  
						case count($fx_a)-2:
						  $map_fx2[] = $vv['id'];
						  break;
						  
						case count($fx_a)-3:
						   $map_fx3[] = $vv['id'];
						  break;
						  
						default:
							
						}
						break;
					}
				}
			}
			$data[$k]['fx1'] = count($map_fx1);
			$data[$k]['fx2'] = count($map_fx2);
			$data[$k]['fx3'] = count($map_fx3);
			$data[$k]['fx_count'] = count($map_fx1)+count($map_fx2)+count($map_fx3);
			
			
			
		}
		
		$options['appid']=C('BB_APPID_client');
		$options['secret']=C('BB_SECRET_client');
		$wx=new \bb\Wechat($options);
		$re=$wx->getQRUrl_str($data[0]['id']);
		$this->assign('tuigungimg',$re);
		
		$this->assign('cache',$data[0]);
		$this->display();
	}
	
	public function sjfx_xxx(){
		$m=M('client_user');
		$map['id'] = $_GET['id'];
		
		$data=$m->where($map)->select();
		
		foreach ($data as $k => $v){
			$wxuser=M('weixin_client_user')->field('headimgurl')->where(array('openid'=>$v['openid']))->find();
			$data[$k]['headimgurl']=$wxuser['headimgurl'];
			
			$map_fx['path'] = array('like','%,'.$data[$k]['id'].'%');
			$map_fx1 = array();
			$map_fx2 = array();
			$map_fx3 = array();
			$fx=$m->where($map_fx)->select();
			
			foreach($fx as $kv=>$vv){
				$fx_a=explode(',',$vv['path']);
				foreach($fx_a as $ke => $ve){
					if($ve == $data[$k]['id'] ){
						switch ($ke)
						{
						case count($fx_a)-1:
						  $map_fx1[] = $vv['id'];
						  break;  
						case count($fx_a)-2:
						  $map_fx2[] = $vv['id'];
						  break;
						  
						case count($fx_a)-3:
						   $map_fx3[] = $vv['id'];
						  break;
						  
						default:
							
						}
						break;
					}
				}
			}
			$data[$k]['fx1'] = $map_fx1;
			$data[$k]['fx2'] = $map_fx2;
			$data[$k]['fx3'] = $map_fx3;
			$data[$k]['fx_count'] = count($map_fx1)+count($map_fx2)+count($map_fx3);
			
			
			
		}
		
		if($_GET['type'] == 1){
			$dataxx=array();
			
			foreach($data[0]['fx1'] as $kddd=>$vddd){
				$m=M('client_user');
				$map['id'] = $vddd;
				$dataxx=$m->where($map)->select();
				$wxuser=M('weixin_client_user')->field('headimgurl')->where(array('openid'=>$dataxx[$kddd]['openid']))->find();
				$dataxx[$kddd]['headimgurl']=$wxuser['headimgurl'];
			}
			
			$this->assign('cache',$dataxx);
			$this->assign('fx_count',count($data[0]['fx1']));
		}elseif($_GET['type'] == 2){
			$dataxx=array();
			
			foreach($data[0]['fx2'] as $kddd=>$vddd){
				$m=M('client_user');
				$map['id'] = $vddd;
				$dataxx=$m->where($map)->select();
				$wxuser=M('weixin_client_user')->field('headimgurl')->where(array('openid'=>$dataxx[$kddd]['openid']))->find();
				$dataxx[$kddd]['headimgurl']=$wxuser['headimgurl'];
			}
			
			$this->assign('cache',$dataxx);
			$this->assign('fx_count',count($data[0]['fx2']));
		}elseif($_GET['type'] == 3){
			$dataxx=array();
			
			foreach($data[0]['fx3'] as $kddd=>$vddd){
				$m=M('client_user');
				$map['id'] = $vddd;
				$dataxx=$m->where($map)->select();
				$wxuser=M('weixin_client_user')->field('headimgurl')->where(array('openid'=>$dataxx[$kddd]['openid']))->find();
				$dataxx[$kddd]['headimgurl']=$wxuser['headimgurl'];
			}
			
			$this->assign('cache',$dataxx);
			$this->assign('fx_count',count($data[0]['fx3']));
		}
		$this->assign('name',$data[0]['username']);
		$this->assign('type',$_GET['type']);

		
		
		$this->display();
	}
	
	
	public function shopset_ay(){
		$arr = M('bb_shop')->where('id = '.$_GET['id'])->find();
		$this->assign('cache',$arr);
		$this->display();
	}
	
}